Add critical if widget has a parent during dispose
authorBenjamin Otte <otte@redhat.com>
Thu, 7 Jan 2021 15:49:52 +0000 (09:49 -0600)
committerMichael Catanzaro <mcatanzaro@gnome.org>
Thu, 7 Jan 2021 17:39:32 +0000 (11:39 -0600)
This is a refcounting bug. Be very verbose about it instead of trying to
call a function that releases a reference to the widget without
references.

gtk/gtkwidget.c

index 239f7735e8b0e0df956a5b846ddb87b07bff7291..6efcdccc4a9ce812bdce84e265724e68f710b3cd 100644 (file)
@@ -7187,7 +7187,13 @@ gtk_widget_dispose (GObject *object)
     gtk_list_list_model_clear (priv->controller_observer);
 
   if (priv->parent)
-    gtk_widget_unparent (widget);
+    {
+      g_critical ("%s %p has a parent %s %p during dispose. Parents hold a reference, so this should not happen.\n"
+                  "Did you call g_object_unref() instead of gtk_widget_unparent()?",
+                  G_OBJECT_TYPE_NAME (widget), widget,
+                  G_OBJECT_TYPE_NAME (priv->parent), priv->parent);
+      priv->parent = NULL;
+    }
 
   while (priv->paintables)
     gtk_widget_paintable_set_widget (priv->paintables->data, NULL);